﻿// ==UserScript==
// @name         pocket-add-redirect
// @namespace    https://user-web.googlecode.com/
// @description  redirect the add-to-pocket page to display the article in pocket
// @include      https://getpocket.com/edit?url=*
// @version      5
// @grant        none
// @copyright    2010+, james_zerty
// ==/UserScript==
try {
	var match = $("a.removeitem").attr("href").match(/deleteid=([^&]+)/);

	if (match && match.length > 1) {
		var id = match[1];
		var url = "http://getpocket.com/a/read/" + id;
		console.log("[pocket-add-redirect] adding link to " + url);
		
		$(".item-detail a.item-link").attr("href", url);
		
		//document.location = url;
	}
	else {
		console.log("[pocket-add-redirect] id not found");
	}
}
catch(ex) {
	console.log("[pocket-add-redirect] error: " + ex.message);
}